package com.allwees.bs.module.pms.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.allwees.bs.core.model.merchant.entity.MerchantModel;
import com.allwees.bs.module.pms.entity.Product;
import com.allwees.core.common.util.reflect.PojoUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.Transient;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class ProductDto extends Product {
	private List<SkuDto> skus;

	/**
	 * 下架原因，仅用于消息事件
	 */
	@Transient
	@TableField(exist = false)
	private String reason;

	/**
	 * 备注，仅用于消息事件
	 */
	@Transient
	@TableField(exist = false)
	private String remark;

	/**
	 * 操作员uuid，仅用于消息事件
	 */
	@Transient
	@TableField(exist = false)
	private String operatorUuid;

	private transient MerchantModel merchant;

	public static ProductDto of(Product product) {
		return PojoUtil.copy(new ProductDto(), product);
	}
}
